package com.ruoyi.project.user.platformKkuserInfo.controller;

import java.util.List;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import com.ruoyi.framework.aspectj.lang.annotation.Log;
import com.ruoyi.framework.aspectj.lang.enums.BusinessType;
import com.ruoyi.project.user.platformKkuserInfo.domain.PlatformKkuserInfo;
import com.ruoyi.project.user.platformKkuserInfo.service.IPlatformKkuserInfoService;
import com.ruoyi.framework.web.controller.BaseController;
import com.ruoyi.framework.web.domain.AjaxResult;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.framework.web.page.TableDataInfo;

/**
 * 用户信息Controller
 * 
 * @author shixiangwen
 * @date 2022-10-11
 */
@Controller
@RequestMapping("/user/platformKkuserInfo")
public class PlatformKkuserInfoController extends BaseController
{
    private String prefix = "user/platformKkuserInfo";

    @Autowired
    private IPlatformKkuserInfoService platformKkuserInfoService;

    @RequiresPermissions("user:platformKkuserInfo:view")
    @GetMapping()
    public String platformKkuserInfo()
    {
        return prefix + "/platformKkuserInfo";
    }

    /**
     * 查询用户信息列表
     */
    @RequiresPermissions("user:platformKkuserInfo:list")
    @PostMapping("/list")
    @ResponseBody
    public TableDataInfo list(PlatformKkuserInfo platformKkuserInfo)
    {
        startPage();
        List<PlatformKkuserInfo> list = platformKkuserInfoService.selectPlatformKkuserInfoList(platformKkuserInfo);
        return getDataTable(list);
    }

    /**
     * 导出用户信息列表
     */
    @RequiresPermissions("user:platformKkuserInfo:export")
    @PostMapping("/export")
    @ResponseBody
    public AjaxResult export(PlatformKkuserInfo platformKkuserInfo)
    {
        List<PlatformKkuserInfo> list = platformKkuserInfoService.selectPlatformKkuserInfoList(platformKkuserInfo);
        ExcelUtil<PlatformKkuserInfo> util = new ExcelUtil<PlatformKkuserInfo>(PlatformKkuserInfo.class);
        return util.exportExcel(list, "platformKkuserInfo");
    }

    /**
     * 新增用户信息
     */
    @GetMapping("/add")
    public String add()
    {
        return prefix + "/add";
    }

    /**
     * 新增保存用户信息
     */
    @RequiresPermissions("user:platformKkuserInfo:add")
    @Log(title = "用户信息", businessType = BusinessType.INSERT)
    @PostMapping("/add")
    @ResponseBody
    public AjaxResult addSave(PlatformKkuserInfo platformKkuserInfo)
    {
        return toAjax(platformKkuserInfoService.insertPlatformKkuserInfo(platformKkuserInfo));
    }

    /**
     * 修改用户信息
     */
    @GetMapping("/edit/{kkuid}")
    public String edit(@PathVariable("kkuid") Long kkuid, ModelMap mmap)
    {
        PlatformKkuserInfo platformKkuserInfo = platformKkuserInfoService.selectPlatformKkuserInfoById(kkuid);
        mmap.put("platformKkuserInfo", platformKkuserInfo);
        return prefix + "/edit";
    }

    /**
     * 修改保存用户信息
     */
    @RequiresPermissions("user:platformKkuserInfo:edit")
    @Log(title = "用户信息", businessType = BusinessType.UPDATE)
    @PostMapping("/edit")
    @ResponseBody
    public AjaxResult editSave(PlatformKkuserInfo platformKkuserInfo)
    {
        return toAjax(platformKkuserInfoService.updatePlatformKkuserInfo(platformKkuserInfo));
    }

    /**
     * 删除用户信息
     */
    @RequiresPermissions("user:platformKkuserInfo:remove")
    @Log(title = "用户信息", businessType = BusinessType.DELETE)
    @PostMapping( "/remove")
    @ResponseBody
    public AjaxResult remove(String ids)
    {
        return toAjax(platformKkuserInfoService.deletePlatformKkuserInfoByIds(ids));
    }
}
